#include "qaddlanguagedialog.h"
#include "ui_qaddlanguagedialog.h"


#include "../../libs/sharedLib/qnamevalidator.h"

#include "../../libs/sharedlib/qprojectcore.h"
#include "../../libs/sharedlib/qlanguagemanager.h"

QAddLanguageDialog::QAddLanguageDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::QAddLanguageDialog),
    m_languageName(new SHAREDLIB::QNameEdit("(.*)",this))
{
    ui->setupUi(this);
    this->setProperty("no-ManhattanStyle",true);

    ui->horizontalLayout->addWidget(m_languageName);

    SHAREDLIB::QProjectCore *core=SHAREDLIB::QProjectCore::getCore();
    SHAREDLIB::QLanguageManager *manager=core->languageManager();
    QStringList list;
    for(int i=0;i<manager->languageCount();i++)
    {
        list.append(manager->getLanguage(i)->property("languageName").toString());
    }
    m_languageName->setIntermediateList(list);
    m_languageName->setFocus();
}

QAddLanguageDialog::~QAddLanguageDialog()
{
    delete ui;
}

void QAddLanguageDialog::on_okBtn_clicked()
{
    QString str=m_languageName->value();
    if(str!="")
    {
        m_language=str;
        close();
    }
}

void QAddLanguageDialog::on_cancelBtn_clicked()
{
    close();
}

QString QAddLanguageDialog::get_language()
{
    return m_language;
}
